//
//  PersonSettingViewController.m
//  动漫之家
//
//  Created by 王少泽 on 16/12/5.
//  Copyright © 2016年 王少泽. All rights reserved.
//

#import "PersonSettingViewController.h"

@interface PersonSettingViewController ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation PersonSettingViewController
{
    UITableView* _settingTable;
}

- (void)viewWillDisappear:(BOOL)animated

{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = YES;
    self.tabBarController.tabBar.hidden = NO;
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden = NO;
    self.tabBarController.tabBar.hidden = YES;
    self.navigationItem.title = @"设置";
    //初始化tableview
    _settingTable = [[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];
    _settingTable.dataSource = self;
    _settingTable.delegate = self;
    [self.view addSubview:_settingTable];
    
}
#pragma mark tableview的各项属性设定
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 4;
    }
    if (section == 1) {
        return 1;
    }
    else if (section == 2) {
        return 3;
    }
    else
    {
        return 0;
    }
}
- (UITableViewCell* )tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString* ruse = @"ruse";
    UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:ruse];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ruse];
    }
    NSArray* readSetting = @[@"个人资料设置",@"移动网络设置",@"漫画阅读设置",@"小说阅读设置"];
    NSArray* otherSetting = @[@"清除缓存",@"意见反馈",@"关于我们"];
    if (indexPath.section == 0) {
        cell.textLabel.text = readSetting[indexPath.row];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
    if (indexPath.section == 1) {
        cell.textLabel.text = @"消息通知";
        cell.detailTextLabel.text = @"一天一次";
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }
    if (indexPath.section == 2) {
        cell.textLabel.text = otherSetting[indexPath.row];
        if (indexPath.row == 0) {
            cell.accessoryType = UITableViewCellAccessoryNone;
            cell.detailTextLabel.text = @"30.00MB";
        }
        else
        {
            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        }
    }
    
    return cell;
}
#pragma mark 调整tableview的页眉页脚
- (NSString* )tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section == 1) {
        return [NSString stringWithFormat:@"通知设置"];
    }
    else
    {
        return nil;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForHeaderInSection:(NSInteger)section
{
//    if (section == 0) {
//        return 0;
//    }
//    if (section == 1) {
//        return 20;
//    }
//    if (section == 2) {
//        return 10;
//    }
//    else
//    {
//        return 0;
//    }
    return 0;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
